// DriveNotes. Copyright (c) 2011, Andrei Senchuk. All rights reserved.
package net.taviscaron.drivenotes.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.taviscaron.drivenotes.web.forward.ActionRedirect;
import net.taviscaron.drivenotes.web.core.Constants;
import net.taviscaron.drivenotes.web.forward.RequestForwarder;

/**
 * Logout action
 * @author Andrei Senchuk
 */
public class LogoutAction implements Action {

    public RequestForwarder doAction(HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession(false);
        if(session != null) {
            session.removeAttribute(Constants.AUTHORIZATION_DATA_ATTR_NAME);
        }
        return new ActionRedirect("login");
    }
}
